'use strict';//开启验证模式

//引入第三方包 -------------------------开始
import Vue from 'vue';
//引入ElementUI
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import locale from 'element-ui/lib/locale/lang/en'; // lang i18n
Vue.prototype.success = (mes) => {
    ElementUI.Message({
        message: mes,
        type: 'success',
        duration: 5 * 1000
    })
}

//引入路由对象
import VueRouter from 'vue-router';
//VueRouter:安装插件
Vue.use(VueRouter)

//Axios:引入axios
import Axios from 'axios';
//Axios:挂载原型
Vue.prototype.$ajax = Axios;

//Axios:默认配置
Axios.defaults.baseURL = 'http://localhost:9502/'


//Moment:引入moment 处理时间格式
import Moment from 'moment';
//引入qs
import qs from 'qs';

Vue.prototype.qs = qs;
Vue.prototype.Moment = Moment;
//VuePreview:引入vue-preview
import VuePreview from 'vue-preview';

Vue.use(VuePreview);
Vue.use(ElementUI, {locale});

//引入第三方包 -------------------------结束

//引入全局组件需要的组件对象 开始


//引入全局组件需要的组件对象 结束

//定义成全局组件或过滤器，大家都能使用 开始
Vue.filter('convertDate', function (value) {
    return Moment(value).format('YYYY-MM-DD HH:mm:ss');
});

Vue.prototype.formatDate = (value)=>{
    return Moment(value).format('YYYY-MM-DD');

}

//定义全局组件或过滤器 结束

//=================================================================
//引入自己的vue文件 ********************开始
import App from './app.vue'
import Login from './components/login/login.vue';
import Home from './components/home/home.vue';
import NotFound from './views/404.vue'
import Main from './views/Main.vue'
import Table from './views/users/usersTable.vue'
import Form from './views/users/Form.vue'
import user from './views/users/user.vue'
import NewsTable from './views/news/newsTable.vue'
import NewsCategory from './views/news/newsCategory.vue'
import PhotosTable from './views/photos/photosTable.vue'
import PhotosCategory from './views/photos/photosCategory.vue'
import GoodsTable from './views/goods/goodsTable.vue'
import CommentsTable from './views/comments/commentsTable.vue'
import echarts from './views/charts/echarts.vue'


//引入自己的vue文件 ********************结束


//VueRouter:创建对象并配置路由规则
let router = new VueRouter({
    routes: [
        {
            path: '/',
            component: Login,
            name: '',
            hidden: true
        },
        {
            path: '/404',
            component: NotFound,
            name: '',
            hidden: true
        },
        //{ path: '/main', component: Main },
        {
            path: '/home',
            component: Home,
            name: '用户管理',
            iconCls: 'el-icon-message',
            children: [
                { path: '/main', component: Main, name: '主页', hidden: true },
                { path: '/table', component: Table, name: '用户修改' },
                { path: '/form', component: Form, name: 'Form' ,hidden: true },
                { path: '/user', component: user, name: '用户查询' },
            ]
        },
        {
            path: '/',
            component: Home,
            name: '新闻管理',
            iconCls: 'el-icon-message',//图标样式class
            children: [
                { path: '/newsTable', component: NewsTable, name: '新闻查询' },
                { path: '/newsCategory', component: NewsCategory, name: '新闻分类管理' }
            ]
        },
        {
            path: '/',
            component: Home,
            name: '图片管理',
            iconCls: 'el-icon-message',
            children: [
                { path: '/photosTable', component: PhotosTable, name: '图片查询' },
                { path: '/photosCategory', component: PhotosCategory, name: '图片分类管理' }
            ]
        },
        {
            path: '/',
            component: Home,
            name: '商品管理',
            iconCls: 'el-icon-message',
            children: [
                { path: '/goodsTable', component: GoodsTable, name: '商品查询' }
            ]
        },
        {
            path: '/',
            component: Home,
            name: '评论管理',
            iconCls: 'el-icon-message',
            children: [
                { path: '/commentsTable', component: CommentsTable, name: '评论查询' }
            ]
        },
        {
            path: '/',
            component: Home,
            name: 'Charts',
            iconCls: 'fa fa-bar-chart',
            children: [
                { path: '/echarts', component: echarts, name: 'echarts' }
            ]
        },
        {
            path: '*',
            hidden: true,
            redirect: { path: '/404' }
        }
    ]

})


//创建vue实例
new Vue({
    el: '#app',
    router,
    render: c => c(App)
})
